import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  final String title = 'Flutter Demo';

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: title,
      debugShowCheckedModeBanner: false,
      theme: new ThemeData(
        primarySwatch: Colors.yellow,
        platform: TargetPlatform.iOS,
      ),
      //home: new ThemeColorPage(),
      //home: new SnackBarPage(),
      home: new TabBarPage(),
    );
  }
}

// 主题颜色的应用
class ThemeColorPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("ThemeColorPage"),
      ),
      body: new Center(
        child: new Container(
          color: Theme.of(context).accentColor,
          child: new Text(
            'Hello Stephen!!!',
            style: Theme.of(context).textTheme.title,
          ),
        ),
      ),
    );
  }
}

// SnackBar
class SnackBarPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("SnackBarPage"),
      ),
      body: new SnackBarWidget(),
    );
  }
}

class SnackBarWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Center(
      child: new RaisedButton(
        onPressed: () {
          final snackBar = new SnackBar(
            content: new Text("I am SnackBar!"),
            action: new SnackBarAction(
                label: 'undo',
                onPressed: () {
                  print('undo');
                }),
          );
          Scaffold.of(context).showSnackBar(snackBar);
        },
        child: new Text("Show SnackBar"),
      ),
    );
  }
}

// TabBar
class TabBarPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new DefaultTabController(
        length: 3,
        child: new Scaffold(
          appBar: new AppBar(
            title: new Text("TabBarPage"),
            bottom: new TabBar(tabs: [
              new Tab(
                icon: new Icon(Icons.directions_car),
              ),
              new Tab(
                icon: new Icon(Icons.directions_transit),
              ),
              new Tab(
                icon: new Icon(Icons.directions_bike),
              ),
            ]),
          ),
          body: new TabBarView(children: [
            new Icon(Icons.directions_car),
            new Icon(Icons.directions_transit),
            new Icon(Icons.directions_bike),
          ]),
        ));
  }
}


